<?php
global $lang;

class PXFLang
{
	static $language;

	public static function get($key,$template)
	{
		global $lang;
		if(array_key_exists($key,$lang))
		{
			return $lang[$key];
		} else 
		{
			if(PXFConfig::PXF_COLLECT_LANGS)
			{
				$db = PXFDataBase::getInstance();
				$q = sprintf("REPLACE INTO translation VALUES('%s','%s','%s','','%s',MD5('%s%s'))",
											self::$language,$key,$template,PXFInstance::$controller,$key,$template);
				$db->query($q);
			}
			return $key;
		}
	}

	public static function init()
	{	
		global $lang;

		if(defined('PXF_ADMIN'))
		{
			include(sprintf('%s/langs/lang.%s.php',PXFConfigAdmin::ADM_PXF_SITE,PXFInstance::$lang));
		}
		elseif(defined('ROOT_ACCESS'))
		{
			include(sprintf('langs/lang.%s.php',PXFInstance::$lang));
		}
		else
		{
			include(sprintf('%s/langs/lang.%s.php',PXFConfig::PXF_SITE,PXFInstance::$lang));
		}
	}
}



?>
